import { request } from "express";
import { response } from "express";

/**
 * @param {response} res
 * @param {request} req
 */
function handleQuery(req, res, next) {
    try {
        for (const key in req.query) {
            if (Object.hasOwnProperty.call(req.query, key)) {
                const element = req.query[key];
                if (element === 'true') {
                    req.query[key] = true
                }
                else if (element === 'false') {
                    req.query[key] = false
                }
            }
        }
        next()
    } catch (error) {
        next(error)
    }
}

export default handleQuery